{% extends 'myadmin/public/base.html' %}

{% block title %}
<title>商品列表</title>
{% endblock %}


{% block con %}
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title  am-cf">商品列表</div>


                </div>
                <div class="widget-body  am-fr">

                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                        <div class="am-form-group">
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <button type="button" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> 新增</button>
                                    <button type="button" class="am-btn am-btn-default am-btn-secondary"><span class="am-icon-save"></span> 保存</button>
                                    <button type="button" class="am-btn am-btn-default am-btn-warning"><span class="am-icon-archive"></span> 审核</button>
                                    <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <form action="{% url "myadmin_goods_index" %}" method="get">
                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                        <div class="am-form-group tpl-table-list-select">
                            <select name="types" data-am-selected="{btnSize: 'sm'}" style="display: none;">
                              <option  {% if request.GET.types == 'all' %} selected {% endif %} value="all">所有类别</option>
                              <option  {% if request.GET.types == 'title' %}  {% endif %} value="username">商品标题</option>

                            </select>
                        </div>
                    </div>
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                        <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
{#                            输入框#}
                            <input value="{{ request.GET.keywords }}" name="keywords" type="text" class="am-form-field" placeholder='请输入您的搜索内容' >
                            <span class="am-input-group-btn">
{#                                搜索按钮#}
                              <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" ></button>
                            </span>
                        </div>
                    </div>
                </form>
                    <div class="am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
{#           顶端表头#}
                            <thead>
                                <tr>
                                   <th>商品缩略图</th>
                                    <th>ID</th>
                                    <th>商品标题</th>
                                    <th>商品价格</th>
                                    <th>商品库存</th>
                                    <th>商品点击量</th>
                                    <th>所属分类</th>
                                    <th>状态</th>
                                    <th>发布时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                              {% for v in goodslist %}
                                <tr>
                                    <td style="text-align: center;" >
                                        <img  style="vertical-align:middle;" src="{{ v.pic }}" class="tpl-table-line-img"   alt="">
                                    </td>
                                    <td class="am-text-middle typeid"  >{{ v.id }}</td>
                                    <td class="am-text-middle">{{ v.title }}</td>
                                    <td class="am-text-middle">{{ v.price }}</td>
                                    <td class="am-text-middle">{{ v.num }}</td>
                                    <td class="am-text-middle">{{ v.clicknum }}</td>
                                    <td class="am-text-middle">{{ v.tid.name }}</td>


                                    <td class="am-text-middle">
                                        {% if v.status == 0 %}
                                        "新发布"
                                        {% elif v.status == 1 %}
                                        '热卖'
                                        {% else %}
                                        "下架"
                                        {% endif %}

                                    </td>



                                    <td class="am-text-middle">{{ v.age }}</td>
{#                        后台数据格式化数据#}
                                    <td class="am-text-middle">{{ v.addtime|date:'Y-m-d H:i:s' }}</td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
{#                                            反向路由a标签跳转#}
                                            <a href="{% url "myadmin_goods_edit" v.id %} " >
                                                <i class="am-icon-pencil"  ></i> 编辑
                                            </a>
                                            <a  href="javascript:void(0)" class="tpl-table-black-operation-del">
                                                <i class="am-icon-trash"  ></i> 删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                              {% endfor %}




                                <!-- more data -->
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">

                        <div class="am-fr">
                            <ul class="am-pagination tpl-pagination">
{#                                <li class="am-disabled"><a href="#">«</a></li>#}
{#                                <li class="am-active"><a href="#">1</a></li>#}

                                {% load pagetag %}
                                {% showpage goodslist.paginator.num_pages request %}


{#                                <li><a href="#">»</a></li>#}
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


    <script type="text/javascript"></script>
//删除元素
<script type="text/javascript">
    $('.tpl-table-black-operation-del').click(function(){

        var id = $(this).parents('tr').find('.typeid').text();
        var d = $(this);


        $.get('{% url "myadmin_goods_del" %}',{'id':id},function(data){
        if(data.error == 0){
            d.parents('tr').remove();
        };
        alert(data.msg);
    },'json');
    });
</script>
















{% endblock %}






